package com.njdj.gps.common.util;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author Yichao.HUANG 2006-7-3
 */
public class BeanLocator {

	private static final String CONTEXT_LOCATION = "/applicationContext.xml";

	private static final String DAO_LOCATION = "/conf/spring/beans-dao.xml";

	private static final String SERVICE_LOCATION = "/conf/spring/beans-service.xml";

	private static final String[] locations = { CONTEXT_LOCATION, DAO_LOCATION,
			SERVICE_LOCATION};


	private static ApplicationContext app;

	public static Object getBean(String name) {
		if (app == null) {
			app = new ClassPathXmlApplicationContext(locations);
		}
		return app.getBean(name);
	}
}
